package com.example.web;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.pojo.Items;
import com.example.security.service.ItemsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/item")
public class ItemRestController {

    @Resource //IOC ======>解耦,多态：  参数 返回值 注入属性
    private ItemsService itemsService ;

    @GetMapping("/")
    public Page<Items> list(){
        //1.校验

        //2.调用service

        Page<Items> itemsPage = itemsService.page(new Page<>(1, 3),
                new QueryWrapper<Items>().lambda().orderByDesc(Items::getCreatetime));
        //3.返回model和view(没有)
        return itemsPage;
    }
}
